#!/system/bin/sh

#
## Added by urain39@cyfan.cf
#

TOPDIR="/sdcard" # Support for non-root
TMPDIRS="$TOPDIR/ramdisk"

[ -f /data/tmpdir.conf ] && TMPDIRS="$(
  sed -E "/^[\t ]*(#|\$)/d;s:\\\$TOPDIR\\\$?:$TOPDIR:g" /data/tmpdir.conf |
    grep -Eo '^((/([^/.\t]{1,2}|[^/.\t]\.|\.[^/.\t]|[^/\t]{3,}))+/?|/)(\t.+)?$'
)"

umask 000

IFS="
"
for LINE in $TMPDIRS; do
  IFS="	"
  read -r DIR OPTS <<DELIM
$LINE
DELIM
  rm -rf "$DIR"/*
done
